//
//  ZXXNetWorkingTools.swift
//  M-Weibo
//
//  Created by ZXX on 16/4/20.
//  Copyright © 2016年 ZXX. All rights reserved.
//

import UIKit
import AFNetworking

class ZXXNetWorkTools: NSObject {

    
///    单例类 全局访问点
    static let sharedNetWorkTools: ZXXNetWorkTools = ZXXNetWorkTools()
///    发送GET方法
    func GET(urlString: String, params:AnyObject?,  success:(response: AnyObject?)->(),failure:(error: NSError?)->()){
        let manager = AFHTTPSessionManager()
        manager.responseSerializer.acceptableContentTypes?.insert("text/plain")
        manager.GET(urlString, parameters: params, progress: nil, success: { (_ , response) -> Void in
            
            success(response: response )
            }) { (_ , error ) -> Void in

                failure(error: error)
        }
    }
///    发送POST方法
    func POST(URLString: String, params: AnyObject?, success: (response: AnyObject?) -> Void, failure: (error: NSError?) -> Void){
        
        
        let manager = AFHTTPSessionManager()
        manager.responseSerializer.acceptableContentTypes?.insert("text/plain")
        manager.POST(URLString, parameters: params, progress: nil , success: { (_ , response) -> Void in
            success(response: response)
            
            }) { (_ , error ) -> Void in
            failure(error: error)
        }
    }
    
///    有过程的POST方法
    func POST() -> () {
        let manager = AFHTTPSessionManager()
        manager.responseSerializer.acceptableContentTypes?.insert("text/plain")
        manager.POST(<#T##URLString: String##String#>, parameters: <#T##AnyObject?#>, constructingBodyWithBlock: <#T##((AFMultipartFormData) -> Void)?##((AFMultipartFormData) -> Void)?##(AFMultipartFormData) -> Void#>, success: <#T##((NSURLSessionDataTask, AnyObject?) -> Void)?##((NSURLSessionDataTask, AnyObject?) -> Void)?##(NSURLSessionDataTask, AnyObject?) -> Void#>, failure: <#T##((NSURLSessionDataTask?, NSError) -> Void)?##((NSURLSessionDataTask?, NSError) -> Void)?##(NSURLSessionDataTask?, NSError) -> Void#>)
        
    }


    
   
}
